package com.liao.furns.dao.impl;

import com.liao.furns.dao.BasicDAO;
import com.liao.furns.dao.OrderItemDAO;
import com.liao.furns.pojo.OrderItem;

import java.util.List;

/**
 * @author lzp
 * @version 1.0
 * lzpnb!
 */
public class OrderItemDAOImpl extends BasicDAO<OrderItem> implements OrderItemDAO {
    @Override
    public int saveOrderItem(OrderItem orderItem) {
        String sql = "INSERT INTO `order_item`(`id`,`name`,`price`,`count`,`total_price`,`order_id`) \n" +
                "VALUES(?,?,?,?,?,?) ";
        return update(sql,orderItem.getId(),orderItem.getName(),orderItem.getPrice(),orderItem.getCount(),orderItem.getTotalPrice(),orderItem.getOrderId());
    }

    @Override
    public List<OrderItem> queryOrderItemByOrderID(String id) {
        String sql = "SELECT `id`,`name`,`price`,`count`,`total_price` totalPrice,`order_id` orderId FROM `order_item` WHERE order_id = ?";
        return queryMulti(sql, OrderItem.class,id);
    }
}
